package com.ibeeking.found.upms.cp.rest.service.impl;

import com.ibeeking.found.upms.cp.rest.service.ICpUserRoleService;
import com.ibeeking.found.upms.service.common.bo.CpUserRoleBO;
import com.ibeeking.found.upms.service.common.dos.CpUserRoleDO;
import com.ibeeking.found.upms.service.mapper.CpUserRoleMapper;
import com.ibeeking.nematos.utils.json.JsonUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName CpUserRoleServiceImpl
 * @Description
 * @Author ibeeking
 * @Date 2021-05-13 11:39
 **/
@Service
public class CpUserRoleServiceImpl implements ICpUserRoleService {

    @Resource
    private CpUserRoleMapper cpUserRoleMapper;

    @Override
    public List<CpUserRoleBO> queryUserRoleByUserIds(List<Long> userIds) {
        List<CpUserRoleDO> cpUserRoleDos = cpUserRoleMapper.selectList(new LambdaQueryWrapper<>(CpUserRoleDO.class)
                .in(CpUserRoleDO::getUserId, userIds)
        );
        return JsonUtils.jsonToList(cpUserRoleDos, CpUserRoleBO.class);
    }
}
